# This file marks a workspace root for the Bazel build system.
# See `https://bazel.build/`.

# This file lists Drake's external dependencies as known to bzlmod. It is used
# in concert with WORKSPACE.bzlmod (which has the workspace-style externals).

module(
    name = "drake",
    # This version number should match MINIMUM_BAZEL_VERSION in CMakeLists.txt.
    bazel_compatibility = [">=8.4.0"],
)

# Add starlark rules.

bazel_dep(name = "apple_support", version = "1.24.5")  # Keep this in sync with cmake/MODULE.bazel.in.  # noqa
bazel_dep(name = "bazel_features", version = "1.38.0")
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.14")
bazel_dep(name = "rules_java", version = "9.1.0")
bazel_dep(name = "rules_jvm_external", version = "6.9")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_python", version = "1.7.0")  # Keep this in sync with cmake/MODULE.bazel.in.  # noqa
bazel_dep(name = "rules_rust", version = "0.67.0")
bazel_dep(name = "rules_shell", version = "0.6.1")

# Customize our toolchains.

cc_configure = use_extension(
    "@rules_cc//cc:extensions.bzl",
    "cc_configure_extension",
)
use_repo(cc_configure, "local_config_cc")

# Add C++ dependencies that are part of our public API.
#
# We declare these dependencies twice -- as modules (bazel_dep) and repository
# rules using pkgconfig in `internal_repositories`. The choice of whether module
# vs pkgconfig will be used is governed by the flags declared at
# drake/tools/flags/BUILD.bazel.
#
# For our CMake builds from source, the "WITH_USER_..." CMake options to choose
# the flavor are translated into the matching Bazel flags.
#
# For wheel builds, the module flavor is always used.
#
# For Bazel builds using Drake as an external, the module flavor is used by
# default but can be changed using the Bazel flags.
#
# For first-party Bazel builds (by Drake Developers), the pkgconfig flavor is
# used by default but can be changed using the Bazel flags.

bazel_dep(name = "eigen", version = "5.0.1", repo_name = "module_eigen")
bazel_dep(name = "fmt", version = "12.1.0", repo_name = "module_fmt")
bazel_dep(name = "spdlog", version = "1.16.0.bcr.2", repo_name = "module_spdlog")  # noqa

# Add C++ module dependencies that are NOT used by Drake's public API, but are
# used by Drake's implementation. Builds have the option to opt-out of these
# dependencies by providing a replacement:
#
# For our CMake builds from source, the "WITH_USER_..." CMake options find a
# user-supplied library are converted into a module override.
#
# For wheel builds, the module flavor is always used.
#
# For Bazel builds using Drake as an external, the module flavor is used by
# default but can be changed using the Bazel flags at @drake//tools/flags.
# For first-party Bazel builds (by Drake Developers), the non-module flavor
# is used by default.

bazel_dep(name = "glib", version = "2.82.2.bcr.6", repo_name = "module_glib")
bazel_dep(name = "zlib", version = "1.3.1.bcr.7", repo_name = "module_zlib")

# Add additional modules we use at build-time (not runtime dependencies).

bazel_dep(name = "libx11", version = "1.8.12.bcr.4")
bazel_dep(name = "nasm", version = "2.16.03.bcr.2")
bazel_dep(name = "patchelf", version = "0.18.0.bcr.1")
bazel_dep(name = "toolchains_llvm", version = "1.5.0")

llvm = use_repo_rule("@toolchains_llvm//toolchain:rules.bzl", "llvm")

llvm(
    name = "llvm",
    llvm_version = "20.1.7",
)

# Load dependencies which are "public", i.e., made available to downstream
# projects.
#
# Downstream projects may load the same `drake_dep_repositories` module
# extension shown below and call its `use_repo` with whatever list of
# repositories they desire to cite from their project. It's safe to call
# `use_repo` on a subset of this list, or not call it at all downstream.
# Its only effect on a downstream project is to make the repository name
# visible to BUILD rules; Drake's own use of the repository is unaffected.

drake_dep_repositories = use_extension(
    "@drake//tools/workspace:default.bzl",
    "drake_dep_repositories",
)
use_repo(
    drake_dep_repositories,
    #
    # Aliases for C++ dependencies that are part of our public API.
    # What these refer to is configurable; see above.
    #
    "eigen",
    "fmt",
    "spdlog",
    #
    # Aliases for C++ dependencies that are used by our implementation.
    # What these refer to is configurable; see above.
    #
    "blas",
    "glib",
    "lapack",
    "opencl",
    "zlib",
    #
    # First-party dependencies (i.e., drake-maintained).
    #
    "drake_models",
    "meshcat",
    #
    # Commercial solver dependencies. In principle, these externals don't need
    # to be public, but it's not too much work for us to provide them.
    #
    "gurobi",
    "mosek",
    "snopt",
    #
    # For convenience, we make our Python toolchains available downstream.
    # If at some point the Bazel ecosystem evolves so that rules_python on its
    # own is sufficiently easy to use, we might decide to mark this internal.
    #
    "python",
    #
    # For now, we'll offer Drake's customized pybind11 as public. Ideally this
    # would be internal, but given the pending port to nanobind, it's not worth
    # deprecating it until we have nanobind ready.
    #
    "pybind11",
    #
    # Deprecated for removal on 2026-02-01.
    #
    "lcm",
    "x11",
)

# Load Java dependencies.

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
    name = "drake_maven_internal",
    artifacts = [
        # Used by @lcm_internal.
        "net.sf.jchart2d:jchart2d:3.3.2",
    ],
)
use_repo(maven, "drake_maven_internal")

# Load developer dependencies that are modules.

bazel_dep(
    name = "buildifier_prebuilt",
    version = "8.2.1",
    dev_dependency = True,
)

bazel_dep(
    name = "gflags",
    version = "2.2.2.bcr.1",
    # TODO(jwnimmer-tri) Set dev_dependency = True on 2026-02-01 with removal
    # of resource_tool deprecation.
)
bazel_dep(
    name = "googletest",
    version = "1.17.0.bcr.2",
    # Ideally we could set dev_dependency = True here, but that would prevent
    # downstream projects from re-using our //common/test_utilities library.
    # Even though that library is not Stable API, historically downstream
    # projects have relied on it, so for now we've chosen not to break it.
)
single_version_override(
    module_name = "googletest",
    patches = [
        "//tools/workspace/googletest:patches/upstream/exception_shadowing.patch",  # noqa
        "//tools/workspace/googletest:patches/upstream/param_iterator_interface.patch",  # noqa
        "//tools/workspace/googletest:patches/add_printers.patch",
        "//tools/workspace/googletest:patches/add_printers_deps.patch",
        "//tools/workspace/googletest:patches/defines.patch",
    ],
)

bazel_dep(
    name = "google_benchmark",
    version = "1.9.4",
    dev_dependency = True,
)
single_version_override(
    module_name = "google_benchmark",
    patches = [
        "//tools/workspace/google_benchmark:patches/console_allocs.patch",
        "//tools/workspace/google_benchmark:patches/remove_overloaded_fixture_set_up.patch",  # noqa
        "//tools/workspace/google_benchmark:patches/reporter_scaling.patch",
        "//tools/workspace/google_benchmark:patches/string_precision.patch",
    ],
)

bazel_dep(
    name = "ruff_prebuilt",
    version = "0.14.4.2",
    dev_dependency = True,
    repo_name = "ruff",
)

# Load dependencies which are "private", i.e., not available for use by
# downstream projects. These are all "internal use only".

internal_repositories = use_extension(
    "@drake//tools/workspace:default.bzl",
    "internal_repositories",
)
use_repo(
    internal_repositories,
    #
    # C/C++ libraries used at runtime.
    #
    "abseil_cpp_internal",
    "ccd_internal",
    "clarabel_cpp_internal",
    "clp_internal",
    "coinutils_internal",
    "common_robotics_utilities_internal",
    "csdp_internal",
    "curl_internal",
    "fcl_internal",
    "gfortran_internal",
    "gklib_internal",
    "gz_math_internal",
    "gz_utils_internal",
    "highway_internal",
    "implib_so_internal",
    "ipopt_internal",
    "lapack_internal",
    "lcm_internal",
    "libjpeg_turbo_internal",
    "libpng_internal",
    "libtiff_internal",
    "metis_internal",
    "msgpack_internal",
    "nanoflann_internal",
    "nlohmann_internal",
    "nlopt_internal",
    "onetbb_internal",
    "osqp_internal",
    "picosha2_internal",
    "pkgconfig_blas_internal",
    "pkgconfig_eigen_internal",
    "pkgconfig_fmt_internal",
    "pkgconfig_glib_internal",
    "pkgconfig_lapack_internal",
    "pkgconfig_opencl_internal",
    "pkgconfig_spdlog_internal",
    "poisson_disk_sampling_internal",
    "qdldl_internal",
    "qhull_internal",
    "scs_internal",
    "sdformat_internal",
    "spgrid_internal",
    "spral_internal",
    "stduuid_internal",
    "suitesparse_internal",
    "tinygltf_internal",
    "tinyobjloader_internal",
    "tinyxml2_internal",
    "usockets_internal",
    "uwebsockets_internal",
    "voxelized_geometry_tools_internal",
    "vtk_internal",
    "yaml_cpp_internal",
    #
    # Python code used when building pydrake.
    #
    "clang_cindex_python3_internal",
    "mypy_extensions_internal",
    "mypy_internal",
    "pathspec_internal",
    "tomli_internal",
    "typing_extensions_internal",
    #
    # Python libraries used at runtime.
    #
    "gymnasium_py_internal",
    "stable_baselines3_internal",
    #
    # Python libraries used at test-time or by maintainers.
    #
    "cpplint_internal",
    "github3_py_internal",
    "mpmath_py_internal",
    "sympy_py_internal",
    "uritemplate_py_internal",
    "xmlrunner_py_internal",
    #
    # Test or example data.
    #
    "dm_control_internal",
    "mujoco_menagerie_internal",
    "ros_xacro_internal",
    #
    # Build system.
    #
    "bazelisk_internal",
    #
    # Documentation.
    #
    "doxygen_internal",
    "styleguide_internal",
    #
    # Deprecated for removal on 2026-02-01.
    #
    "pkgconfig_x11_internal",
)

crate_universe = use_extension(
    "//tools/workspace/crate_universe:extensions.bzl",
    "crate_universe",
)
use_repo(
    crate_universe,
    "crate",
    "crate__cfg-if-1.0.3",
    "crate__clarabel-0.11.1",
    "crate__paste-1.0.15",
    "crate_licenses",
)
